<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="/WEB-INF/template/template.xhtml">	
	<ui:define name="content">
	<br/>
	
	<script type="text/javascript">
		function showText() {
			/*
			var spans = document.getElementsByTagName("span");
			
			for (var i=0; spans.length &gt; i; i++) {				
				if (spans[i].innerHTML.length &lt; 14) {
					spans[i].style.display = 'none';
				}
			}
			*/
		}
	</script>
	
	<div class="middle">
			<h3><h:outputText value="#{msg.BU_editStatus_editStatus_header}"/></h3>
	</div>
	
	<h:form>
		<h:panelGrid class="panelGrid" border="0" columns="5">
			<h:outputText value="#{msg.BU_editStatus_editStatus_status}"></h:outputText>
			<h:selectOneMenu id="statSelect" value="#{statusBean.user.status}">
				<f:selectItem itemLabel="Available" itemValue="Available"></f:selectItem>
				<f:selectItem itemLabel="Busy" itemValue="Busy"></f:selectItem>
				<f:selectItem itemLabel="Stepped Out" itemValue="Stepped Out"></f:selectItem>
				<f:selectItem itemLabel="Be Right Back" itemValue="Be Right Back"></f:selectItem>
				<f:selectItem itemLabel="Not at My Desk" itemValue="Not at My Desk"></f:selectItem>
				<f:selectItem itemLabel="On the Phone" itemValue="On the Phone"></f:selectItem>
				<f:selectItem itemLabel="Other" itemValue="Other"></f:selectItem>
				<f:ajax render="statInput"></f:ajax>
			</h:selectOneMenu>
			<h:panelGrid id="statInput">
				<h:inputText id="stat" rendered="#{statusBean.user.status == 'Other'}" value="#{statusBean.user.status}"></h:inputText>
			</h:panelGrid>
			<h:commandButton class="button" value="#{msg.BU_editStatus_editStatus_updateButton}" actionListener="#{statusBean.setOnlineStatus}">
				<f:ajax execute="stat" render="resourceTable statSelect statInput"></f:ajax>
			</h:commandButton>
			<h:commandButton class="button" value="#{msg.BU_editStatus_editStatus_refreshButton}" actionListener="#{statusBean.refresh}">
				<f:ajax render="resourceTable"></f:ajax>
			</h:commandButton>
		</h:panelGrid>

		<br/>
		<div class="middle">
			<h3><h:outputText value="#{msg.BU_editStatus_editStatus_userLogHeader}"/></h3>
		</div>
		
		
		<h:dataTable class="table" columnClasses="" id="resourceTable" border="0" value="#{statusBean.listResourceUser}" var="resUser">
			<h:column>
				<f:facet name="header"><h:outputText value="#{msg.BU_editStatus_editStatus_tableHead_ip}"/></f:facet>
				<h:outputLabel style="color: green; font-weight:bold; font-size: 130%" rendered="#{resUser.res.status == 'online' and resUser.res.ip == statusBean.user.ip}" value="#{resUser.res.ip}"></h:outputLabel>
				<h:outputLabel style="color: green" rendered="#{resUser.res.status == 'online' and resUser.res.ip != statusBean.user.ip}" value="#{resUser.res.ip}"></h:outputLabel>
				<h:outputLabel style="color: #666362" rendered="#{resUser.res.status == 'offline'}" value="#{resUser.res.ip}"></h:outputLabel>
			</h:column>
			
			<h:column>
				<f:facet name="header"><h:outputText value="#{msg.BU_editStatus_editStatus_tableHead_name}"/></f:facet>
				<h:outputLabel style="color: green; font-weight:bold; font-size: 130%" rendered="#{resUser.res.ip == statusBean.user.ip}" value="#{statusBean.user.name}"></h:outputLabel>
				<h:outputLabel style="color: green" rendered="#{resUser.res.ip != statusBean.user.ip and resUser.user != null}" value="#{resUser.user.name}"></h:outputLabel>
				<h:outputLabel style="color: green" rendered="#{resUser.res.ip != statusBean.user.ip and resUser.isPrinter == 'yes'}" value="#{resUser.res.name}"></h:outputLabel>
			</h:column>
			
			<h:column>
				<f:facet name="header"><h:outputText value="#{msg.BU_editStatus_editStatus_tableHead_status}"/></f:facet>
				<div class="forTooltip" onmouseover="showText()">
					<a class="tooltip">
						<span style="font-weight:bold; font-size: 130%">#{statusBean.user.status}</span>
						<h:outputLabel style="color: green; font-weight:bold; font-size: 130%" rendered="#{resUser.res.ip == statusBean.user.ip}" value="#{statusBean.user.status}"></h:outputLabel>
					</a>
					<a class="tooltip">
						<span>#{resUser.user.status}</span>
						<h:outputLabel style="color: green" rendered="#{resUser.res.ip != statusBean.user.ip and resUser.user != null}" value="#{resUser.user.status}"></h:outputLabel>	
					</a>	
					<a class="tooltip">
						<span>#{resUser.res.status}</span>
						<h:outputLabel style="color: green" rendered="#{resUser.res.ip != statusBean.user.ip and resUser.isPrinter == 'yes'}" value="#{resUser.res.status}"></h:outputLabel>
					</a>
				</div>
			</h:column>
			
		</h:dataTable>
	
	</h:form>
	</ui:define>
</ui:composition>
</html>